package com.grad.webstudy.enums;

/**
 * @Description: 支持代码类型
 * @Author: zjf
 * @Date: 2020/1/14 16:26.
 */
public enum CodeEnum {
    HTML(-1,"HTML/CSS",""),
    JAVA(1, "Java", "java"),
    GCC(2, "C++", "cpp"),
    PYTHON(3, "Python", "py"),
    PHP(4, "PHP", "php"),
    RUBY(5, "Ruby", "rb"),
    KOTLIN(6, "Kotlin", "kt"),
    GO(7, "Go", "go"),
    PERL(8,"Perl","pl"),
    SWIFT(9,"Swift","swift"),
    ;


    private int codeNumber;

    private String suffix; //对应语言文件后缀

    private String type;//对应语言的类型

    CodeEnum(int codeNumber, String type, String suffix) {
        this.codeNumber = codeNumber;
        this.suffix = suffix;
        this.type = type;
    }

    public int getCodeNumber() {
        return codeNumber;
    }

    public void setCodeNumber(int codeNumber) {
        this.codeNumber = codeNumber;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static String getSuffix(int codeNumber) {
        for (CodeEnum codeEnum : CodeEnum.values()) {
            if (codeEnum.getCodeNumber() == codeNumber) {
                return codeEnum.getSuffix();
            }
        }
        return null;
    }

    public static String getType(int codeNumber) {
        for (CodeEnum codeEnum : CodeEnum.values()) {
            if (codeEnum.getCodeNumber() == codeNumber) {
                return codeEnum.getType();
            }
        }
        return null;
    }
}
